home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / LINUX / NFS_FS.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  9KB  |  283 lines

  1. /*
  2.  *  linux/include/linux/nfs_fs.h
  3.  *
  4.  *  Copyright (C) 1992  Rick Sladkey
  5.  *
  6.  *  OS-specific nfs filesystem definitions and declarations
  7.  */
  8.  
  9. #ifndef _LINUX_NFS_FS_H
  10. #define _LINUX_NFS_FS_H
  11.  
  12. #include <linux/signal.h>
  13. #include <linux/sched.h>
  14. #include <linux/in.h>
  15.  
  16. #include <linux/sunrpc/sched.h>
  17. #include <linux/nfs.h>
  18. #include <linux/nfs_mount.h>
  19.  
  20. /*
  21.  * Enable debugging support for nfs client.
  22.  * Requires RPC_DEBUG.
  23.  */
  24. #ifdef RPC_DEBUG
  25. # define NFS_DEBUG
  26. #endif
  27.  
  28. /*
  29.  * NFS_MAX_DIRCACHE controls the number of simultaneously cached
  30.  * directory chunks. Each chunk holds the list of nfs_entry's returned
  31.  * in a single readdir call in a memory region of size PAGE_SIZE.
  32.  *
  33.  * Note that at most server->rsize bytes of the cache memory are used.
  34.  */
  35. #define NFS_MAX_DIRCACHE        16
  36.  
  37. #define NFS_MAX_FILE_IO_BUFFER_SIZE    16384
  38. #define NFS_DEF_FILE_IO_BUFFER_SIZE    4096
  39.  
  40. /*
  41.  * The upper limit on timeouts for the exponential backoff algorithm.
  42.  */
  43. #define NFS_MAX_RPC_TIMEOUT        (6*HZ)
  44.  
  45. /*
  46.  * Size of the lookup cache in units of number of entries cached.
  47.  * It is better not to make this too large although the optimum
  48.  * depends on a usage and environment.
  49.  */
  50. #define NFS_LOOKUP_CACHE_SIZE        64
  51.  
  52. /*
  53.  * superblock magic number for NFS
  54.  */
  55. #define NFS_SUPER_MAGIC            0x6969
  56.  
  57. #define NFS_FH(dentry)            ((struct nfs_fh *) ((dentry)->d_fsdata))
  58. #define NFS_DSERVER(dentry)        (&(dentry)->d_sb->u.nfs_sb.s_server)
  59. #define NFS_SERVER(inode)        (&(inode)->i_sb->u.nfs_sb.s_server)
  60. #define NFS_CLIENT(inode)        (NFS_SERVER(inode)->client)
  61. #define NFS_ADDR(inode)            (RPC_PEERADDR(NFS_CLIENT(inode)))
  62. #define NFS_CONGESTED(inode)        (RPC_CONGESTED(NFS_CLIENT(inode)))
  63.  
  64. #define NFS_READTIME(inode)        ((inode)->u.nfs_i.read_cache_jiffies)
  65. #define NFS_OLDMTIME(inode)        ((inode)->u.nfs_i.read_cache_mtime)
  66. #define NFS_CACHEINV(inode) \
  67. do { \
  68.     NFS_READTIME(inode) = jiffies - 1000000; \
  69.     NFS_OLDMTIME(inode) = 0; \
  70. } while (0)
  71. #define NFS_ATTRTIMEO(inode)        ((inode)->u.nfs_i.attrtimeo)
  72. #define NFS_MINATTRTIMEO(inode) \
  73.     (S_ISDIR(inode->i_mode)? NFS_SERVER(inode)->acdirmin \
  74.                    : NFS_SERVER(inode)->acregmin)
  75. #define NFS_MAXATTRTIMEO(inode) \
  76.     (S_ISDIR(inode->i_mode)? NFS_SERVER(inode)->acdirmax \
  77.                    : NFS_SERVER(inode)->acregmax)
  78.  
  79. #define NFS_FLAGS(inode)        ((inode)->u.nfs_i.flags)
  80. #define NFS_REVALIDATING(inode)        (NFS_FLAGS(inode) & NFS_INO_REVALIDATE)
  81. #define NFS_WRITEBACK(inode)        ((inode)->u.nfs_i.writeback)
  82.  
  83. /*
  84.  * These are the default flags for swap requests
  85.  */
  86. #define NFS_RPC_SWAPFLAGS        (RPC_TASK_SWAPPER|RPC_TASK_ROOTCREDS)
  87.  
  88. /* Flags in the RPC client structure */
  89. #define NFS_CLNTF_BUFSIZE    0x0001    /* readdir buffer in longwords */
  90.  
  91. #ifdef __KERNEL__
  92.  
  93. /*
  94.  * This struct describes a file region to be written.
  95.  * It's kind of a pity we have to keep all these lists ourselves, rather
  96.  * than sticking an extra pointer into struct page.
  97.  */
  98. struct nfs_wreq {
  99.     struct rpc_listitem    wb_list;    /* linked list of req's */
  100.     struct rpc_task        wb_task;    /* RPC task */
  101.     struct file *        wb_file;    /* dentry referenced */
  102.     struct page *        wb_page;    /* page to be written */
  103.     struct wait_queue *    wb_wait;    /* wait for completion */
  104.     unsigned int        wb_offset;    /* offset within page */
  105.     unsigned int        wb_bytes;    /* dirty range */
  106.     unsigned int        wb_count;    /* user count */
  107.     int            wb_status;
  108.     pid_t            wb_pid;        /* owner process */
  109.     unsigned short        wb_flags;    /* status flags */
  110.  
  111.     struct nfs_writeargs    wb_args;    /* NFS RPC stuff */
  112.     struct nfs_fattr    wb_fattr;    /* file attributes */
  113. };
  114.  
  115. #define WB_NEXT(req)        ((struct nfs_wreq *) ((req)->wb_list.next))
  116.  
  117. /*
  118.  * Various flags for wb_flags
  119.  */
  120. #define NFS_WRITE_CANCELLED    0x0004    /* has been cancelled */
  121. #define NFS_WRITE_UNCOMMITTED    0x0008    /* written but uncommitted (NFSv3) */
  122. #define NFS_WRITE_INVALIDATE    0x0010    /* invalidate after write */
  123. #define NFS_WRITE_INPROGRESS    0x0100    /* RPC call in progress */
  124. #define NFS_WRITE_COMPLETE    0x0200    /* RPC call completed */
  125.  
  126. #define WB_CANCELLED(req)    ((req)->wb_flags & NFS_WRITE_CANCELLED)
  127. #define WB_UNCOMMITTED(req)    ((req)->wb_flags & NFS_WRITE_UNCOMMITTED)
  128. #define WB_INVALIDATE(req)    ((req)->wb_flags & NFS_WRITE_INVALIDATE)
  129. #define WB_INPROGRESS(req)    ((req)->wb_flags & NFS_WRITE_INPROGRESS)
  130. #define WB_COMPLETE(req)    ((req)->wb_flags & NFS_WRITE_COMPLETE)
  131.  
  132. /*
  133.  * linux/fs/nfs/proc.c
  134.  */
  135. extern int nfs_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
  136.             struct nfs_fattr *fattr);
  137. extern int nfs_proc_setattr(struct nfs_server *server, struct nfs_fh *fhandle,
  138.             struct nfs_sattr *sattr, struct nfs_fattr *fattr);
  139. extern int nfs_proc_lookup(struct nfs_server *server, struct nfs_fh *dir,
  140.             const char *name, struct nfs_fh *fhandle,
  141.             struct nfs_fattr *fattr);
  142. extern int nfs_proc_readlink(struct nfs_server *server, struct nfs_fh *fhandle,
  143.             void **p0, char **string, unsigned int *len,
  144.             unsigned int maxlen);
  145. extern int nfs_proc_read(struct nfs_server *server, struct nfs_fh *fhandle,
  146.             int swap, unsigned long offset, unsigned int count,
  147.             void *buffer, struct nfs_fattr *fattr);
  148. extern int nfs_proc_write(struct nfs_server *server, struct nfs_fh *fhandle,
  149.             int swap, unsigned long offset, unsigned int count,
  150.             const void *buffer, struct nfs_fattr *fattr);
  151. extern int nfs_proc_create(struct nfs_server *server, struct nfs_fh *dir,
  152.             const char *name, struct nfs_sattr *sattr,
  153.             struct nfs_fh *fhandle, struct nfs_fattr *fattr);
  154. extern int nfs_proc_remove(struct nfs_server *server, struct nfs_fh *dir,
  155.             const char *name);
  156. extern int nfs_proc_rename(struct nfs_server *server,
  157.             struct nfs_fh *old_dir, const char *old_name,
  158.             struct nfs_fh *new_dir, const char *new_name);
  159. extern int nfs_proc_link(struct nfs_server *server, struct nfs_fh *fhandle,
  160.             struct nfs_fh *dir, const char *name);
  161. extern int nfs_proc_symlink(struct nfs_server *server, struct nfs_fh *dir,
  162.             const char *name, const char *path,
  163.             struct nfs_sattr *sattr);
  164. extern int nfs_proc_mkdir(struct nfs_server *server, struct nfs_fh *dir,
  165.             const char *name, struct nfs_sattr *sattr,
  166.             struct nfs_fh *fhandle, struct nfs_fattr *fattr);
  167. extern int nfs_proc_rmdir(struct nfs_server *server, struct nfs_fh *dir,
  168.             const char *name);
  169. extern int nfs_proc_readdir(struct nfs_server *server, struct nfs_fh *fhandle,
  170.             u32 cookie, unsigned int size, __u32 *entry);
  171. extern int nfs_proc_statfs(struct nfs_server *server, struct nfs_fh *fhandle,
  172.             struct nfs_fsinfo *res);
  173.  
  174.  
  175. /*
  176.  * linux/fs/nfs/inode.c
  177.  */
  178. extern struct super_block *nfs_read_super(struct super_block *, void *, int);
  179. extern int init_nfs_fs(void);
  180. extern struct inode *nfs_fhget(struct dentry *, struct nfs_fh *,
  181.                 struct nfs_fattr *);
  182. extern int nfs_refresh_inode(struct inode *, struct nfs_fattr *);
  183. extern int nfs_revalidate(struct dentry *);
  184. extern int _nfs_revalidate_inode(struct nfs_server *, struct dentry *);
  185.  
  186. /*
  187.  * linux/fs/nfs/file.c
  188.  */
  189. extern struct inode_operations nfs_file_inode_operations;
  190.  
  191. /*
  192.  * linux/fs/nfs/dir.c
  193.  */
  194. extern struct inode_operations nfs_dir_inode_operations;
  195. extern struct dentry_operations nfs_dentry_operations;
  196. extern void nfs_free_dircache(void);
  197. extern void nfs_invalidate_dircache(struct inode *);
  198. extern void nfs_invalidate_dircache_sb(struct super_block *);
  199.  
  200. /*
  201.  * linux/fs/nfs/symlink.c
  202.  */
  203. extern struct inode_operations nfs_symlink_inode_operations;
  204.  
  205. /*
  206.  * linux/fs/nfs/locks.c
  207.  */
  208. extern int nfs_lock(struct file *, int, struct file_lock *);
  209.  
  210. /*
  211.  * linux/fs/nfs/write.c
  212.  */
  213. extern int  nfs_writepage(struct file *, struct page *);
  214. extern int  nfs_check_failed_request(struct inode *);
  215.  
  216. /*
  217.  * Try to write back everything synchronously (but check the
  218.  * return value!)
  219.  */
  220. extern int  nfs_wb_all(struct inode *);
  221. extern int  nfs_wb_page(struct inode *, struct page *);
  222. extern int  nfs_wb_file(struct inode *, struct file *);
  223.  
  224. /*
  225.  * Invalidate write-backs, possibly trying to write them
  226.  * back first..
  227.  */
  228. extern void nfs_inval(struct inode *);
  229. extern int  nfs_updatepage(struct file *, struct page *, unsigned long, unsigned int, int);
  230.  
  231. /*
  232.  * linux/fs/nfs/read.c
  233.  */
  234. extern int  nfs_readpage(struct file *, struct page *);
  235.  
  236. /*
  237.  * linux/fs/mount_clnt.c
  238.  * (Used only by nfsroot module)
  239.  */
  240. extern int  nfs_mount(struct sockaddr_in *, char *, struct nfs_fh *);
  241.  
  242. /*
  243.  * inline functions
  244.  */
  245. static inline int
  246. nfs_revalidate_inode(struct nfs_server *server, struct dentry *dentry)
  247. {
  248.     struct inode *inode = dentry->d_inode;
  249.     if (jiffies - NFS_READTIME(inode) < NFS_ATTRTIMEO(inode))
  250.         return 0;
  251.     return _nfs_revalidate_inode(server, dentry);
  252. }
  253.  
  254. /* NFS root */
  255.  
  256. extern int nfs_root_mount(struct super_block *sb);
  257.  
  258. #endif /* __KERNEL__ */
  259.  
  260. /*
  261.  * NFS debug flags
  262.  */
  263. #define NFSDBG_VFS        0x0001
  264. #define NFSDBG_DIRCACHE        0x0002
  265. #define NFSDBG_LOOKUPCACHE    0x0004
  266. #define NFSDBG_PAGECACHE    0x0008
  267. #define NFSDBG_PROC        0x0010
  268. #define NFSDBG_XDR        0x0020
  269. #define NFSDBG_FILE        0x0040
  270. #define NFSDBG_ROOT        0x0080
  271. #define NFSDBG_ALL        0xFFFF
  272.  
  273. #ifdef __KERNEL__
  274. # undef ifdebug
  275. # ifdef NFS_DEBUG
  276. #  define ifdebug(fac)        if (nfs_debug & NFSDBG_##fac)
  277. # else
  278. #  define ifdebug(fac)        if (0)
  279. # endif
  280. #endif /* __KERNEL */
  281.  
  282. #endif
  283.